package com.xn.myyxcampus.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * 验证QQ,手机号，Email,中文
 * 正则
 * @author Fay
 */

public class VerifyUtil {
	 /**
     * 验证字符串是否是email
     * @param str
     * @return
     */
	public static boolean isEmail(String str) {
		Pattern pattern = Pattern.compile(
				 "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*",
				Pattern.CASE_INSENSITIVE);
		Matcher matcher = pattern.matcher(str);
		if (matcher.matches()) {
			return true;
		} else {
			return false;
		}
	}
    
    /**
     * 验证是否是手机号码
     * @param str
     * @return
     */
   public static boolean isCellphone(String str){
     Pattern patternPhone = Pattern.compile("1[0-9]{10}");
     Matcher matcherPhone = patternPhone.matcher(str); 
     if (matcherPhone.matches()) {
            return true;
     }else {
           return false;
     }	  
  }
   /**
    * 验证是否是QQ号码
    * @param str
    * @return
    */
   public static boolean isQQ(String str) {
       Pattern pattern = Pattern.compile("[1-9][0-9]{4,14}");
       Matcher matcher = pattern.matcher(str); 
       if (matcher.matches()) {
           return true;
       }else {
           return false;
       }	  
    }

	 /**
	  * 判断是否包含中文
	  * @param str
	  * @return
	  */
   public static boolean isUser(String str) {
	   String reg= "^[A-Za-z0-9]+";//判断是否是下划线，数字，字母
	   Pattern pat = Pattern.compile(reg);
	   Matcher mat = pat.matcher(str);
	   return mat.matches();
}

}
